package com.power.ding.dao;

import com.power.ding.model.Di_rel_dept_target;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;

import javax.transaction.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * 司法组织机构-被申请人 持久层(hibernate)
 */

public interface Di_rel_dept_targetDao extends JpaRepository<Di_rel_dept_target, Serializable>, JpaSpecificationExecutor<Di_rel_dept_target>, Repository<Di_rel_dept_target, Serializable>, Di_rel_dept_targetDaoCustom<Di_rel_dept_target, Serializable> {

   @Modifying
   @Transactional
   @Query("delete  from Di_rel_dept_target s where  s.id in (:ids) ")
   void removeByIds(@Param("ids") List<Integer> ids);


   @Query(value = "select a.id, orgname, adid, contactuser, b.username,b.mobile from Di_rel_dept_target a left join di_user b on a.contactuser = b.id", nativeQuery = true)
   List<Map<String,Object>> queryAllTargetOrg();
}
